import re


class ProcessLog:
    def __init__(self, raw_text: str):
        """程序输出文本类"""
        self.raw_text = raw_text.strip("\n").strip("\r")
        self.text = self.deal_color_log(self.raw_text)

    # 处理彩色输出
    @staticmethod
    def deal_color_log(content: str) -> str:
        if re.search("\033\\[.*?m", content):
            content = re.sub("\033\\[.*?m", "", content)
        return content


class RobotMsg:
    def __init__(self, text=""):
        """机器人消息类"""
        self.text = re.sub("\\[CQ:.+?]", "", text)
        self.length = len(self.text)

    def __add__(self, other):
        tmp = RobotMsg()
        if self.length:
            tmp.text = self.text + "\n" + other.text
        else:
            tmp.text = other.text
        tmp.length = self.length + other.length
        return tmp
